<form class="area" method="post" style="padding-bottom:40px;">
    <dl class="optBox mt20">
        <dt class="opt"><label class="lb" for="">类型</label></dt>
        <dd class="opCon" id="ssq">
            <select name="type" id="type">
                <option value="1">
                    图片
                </option>
                <option value="2">
                    视频
                </option>
                <option value="3">
                    音频
                </option>
            </select> 
        </dd>
    </dl>
    <dl class="optBox mt20">
        <dt class="opt"><label class="lb" for="">素材组名</label></dt>
        <dd class="opCon">
            <input type="text" id="title" class="txt" placeholder="请输入素材组名" value="">
            <p class="tip"></p>
        </dd>
    </dl>
    <p class="mt20 tc"><input type="button" style="width: 100px; height:30px;" value="提交"   id="add"  /> <input type="button" style="width: 100px; height:30px;"  value="返回"  class="btn-back"  /></p>
</form>


<input type="hidden" id="ajaxAdd" value="{{url("material/ajaxMaterialGroupAdd")}}">




<script type="text/javascript">
    $(window).load(function () {
        $('#add').click(function () {
            var title = $("#title").val();
            var type = $("#type").val();
            var ajaxAddUrl = $("#ajaxAdd").val();
            if (title == "") {
                alert('请输入素材组名');
                return false;
            }
            var json = {
                "type": type,
                "title": title,
            };
            var successFunction = function (data) {
                if (data.status == 200) {
                    alert("添加成功");
                    window.location.href = "{{url('material/materialGroup')}}";
                } else if (data.status == -1) {
                    alert(data.info);
                }
            };
            var errorFunction = function () {

            };
            $.ajax({
                url: ajaxAddUrl,
                data: json,
                type: "post",
                error: errorFunction,
                success: successFunction
            });
        });
    });

</script>
